function openBook(b){
	
	var IMAGES_SRC = "/getFile?fileName=";
	
	//Reset current book
	sceneList.removeAllScenes();
	
	
	//Atributos del libro
	$('#book-name-input').val(b.bookName);
	$('#version-engine').text(b.versionEngine);
		
	//TODO: load input files
	
	if (b.iOSDevice){
		deviceController.setDevice(b.iOSDevice);
	}
	else {
		return false;
	}
	
	//Cargar escenas del libro
	$.each(b.scenes, function(sceneName, scene){
		
		var newScene = sceneList.addScene(sceneName, scene);
		
		if (scene.bookObjects){
			_loadActors(scene, newScene, null);	
		}
	});
	
	//Seleccionar escena
	if (!$.isEmptyObject(b.scenes)){
		sceneList.scenes[0].item.click();
	}
	
	
	//Renderizar canvas
	mainCanvas.canvas._objects.sort(function(a,b){return a.zindex-b.zindex;});
	mainCanvas.canvas.renderAll();	
	
	
	//Cargar atributo opening scene

	$('#opening-scene').data("kendoDropDownList").select(function(dataItem) {
	    return dataItem.text === b.openingScene;
	});
	
	return true;
	
	
	
	
	/*
	 * PRIVATE FUNCTIONS
	 */
	function _loadActors(bookScene, p_scene, parent){
		
		$.each(bookScene.bookObjects || bookScene.children, function(actorName, actor){
			
			var settings = {
				  text: actorName
				, draggable: actor.draggable
				, touchable: actor.touchable
				, initState: actor.initState
				, group: actor.group
				, batchNode: actor.batchNode
			}
			
			stateController.loadValue(actor.initState);
			
			if (actor.type == "actorType"){
				
				$.extend(settings, {
					source: IMAGES_SRC + actor.image
				})
				
				p_scene.canvas.addLocalImage(settings.source,function(p_imageObj){
					
					var leaf = p_scene.tree.treeView.append(settings, parent);
					var uid = leaf.attr('data-uid');
					
					p_imageObj.set('scaleX', actor.scale.split(",")[0] * deviceController.canvasRatio).setCoords();
					p_imageObj.set('scaleY', actor.scale.split(",")[1] * deviceController.canvasRatio).setCoords();
					p_imageObj.set('angle', actor.rotation);
					
					var l = actor.position.split(",")[0] * deviceController.canvasRatio;
					var t = actor.position.split(",")[1];
					t = deviceController.getDadaHeightFromCocos(t);
					t = t * deviceController.canvasRatio;
					
					p_imageObj.set('top', t).setCoords();
					p_imageObj.set('left', l).setCoords();
					p_imageObj.set('zindex', actor.zindex).setCoords();
					p_imageObj.setOpacity(actor.opacity).setCoords();

					//incluye en el árbol la referencia al nodo
					p_scene.tree.treeView.dataSource.getByUid(uid).imageObj = p_imageObj;
					p_scene.tree.treeView.dataSource.getByUid(uid).imageObj.node = leaf;
					
					if (actor.children){
						_loadActors(actor, p_scene, leaf);
					}
					
					_loadSequences(actor, uid);
				
					mainCanvas.canvas._objects.sort(function(a,b){return a.zindex-b.zindex;});
					mainCanvas.canvas.renderAll();
				});
			}
			else if (actor.type == "textType"){
				
				var l = actor.position.split(",")[0] * deviceController.canvasRatio;
				var t = actor.position.split(",")[1];
				t = deviceController.getDadaHeightFromCocos(t);
				t = t * deviceController.canvasRatio;
				
				$.extend(settings, {
					font: actor.fontName,
					fontFamily: 'Delicious_500',
					left: l,
					top: t,
			        fontSize: actor.fontSize,
			        textAlign: actor.fontAlignment,
			        fill: '#'+actor.color,
				});

				p_scene.canvas.addText(settings.text, settings, function(p_imageObj){
					
					//eliminar caracter #
					settings.fill = settings.fill.substring(1);
					
					var leaf = p_scene.tree.treeView.append(settings, parent);
					var uid = leaf.attr('data-uid');
					
					p_imageObj.set('scaleX', actor.scale.split(",")[0] * deviceController.canvasRatio).setCoords();
					p_imageObj.set('scaleY', actor.scale.split(",")[1] * deviceController.canvasRatio).setCoords();
					p_imageObj.set('angle', actor.rotation);
					p_imageObj.set('zindex', actor.zindex).setCoords();
					p_imageObj.setOpacity(actor.opacity).setCoords();

					//incluye en el árbol la referencia al nodo
					p_scene.tree.treeView.dataSource.getByUid(uid).imageObj = p_imageObj;
					p_scene.tree.treeView.dataSource.getByUid(uid).imageObj.node = leaf;
					
					if (actor.children){
						_loadActors(actor, p_scene, leaf);
					}
				
					_loadSequences(actor, uid);
					
					mainCanvas.canvas._objects.sort(function(a,b){return a.zindex-b.zindex;});
					mainCanvas.canvas.renderAll();
				});
				
			}

		})
		
		
		function _loadSequences(actor, uid){
		
			//load sequences
			if (actor.actions){
				
				var   tree = p_scene.tree.treeView.dataSource.getByUid(uid)
					, idSq = 0
				;
				
				if (!tree.hasOwnProperty('sequences')){
					tree.sequences = [];
				}
				
				$.each(actor.actions, function(p_eventType, sequence){
					
					var lseq = tree.sequences.length;
					
					var eventType = p_eventType.split('{')[0];
					
					if (p_eventType.split('{').length > 1){
						
						var state = p_eventType.split('{')[1].substring(0, p_eventType.split('{')[1].length-1)
					}
					else {
						var state = "Default";
					}
					
					tree.sequences[lseq] = {
						  idSq: idSq
						, domObj: null
						, actions: []
					    , repeat: parseInt(sequence[0].repeat)
					};
					
					$.each(sequence[0].config, function(i, a){
						
						var lact = tree.sequences[lseq].actions.length;
						
						tree.sequences[lseq].actions[lact] = {
								
							  domObj: null
							, idAction: ""
							, action: {
									
									  event: eventType
									, name: a.name
									, type: a.type
									, state: state
									, repeat: a.repeat
							}
						}
						
						if (a.hasOwnProperty('duration')){
							tree.sequences[lseq].actions[lact].action.duration = a.duration
						}
						
						if (a.hasOwnProperty('fx')){
							tree.sequences[lseq].actions[lact].action.fx = a.fx
						}
						if (a.hasOwnProperty('config')){
							
							if (a.type == "DDSpawn"){
								
								tree.sequences[lseq].actions[lact].action.cfg1 = {} 
								
								$.each(a.config, function(i,e){
									
									var cfg1 = e.config[0];
									
									if (cfg1.indexOf(',') != -1){
										
										var t = cfg1.split(',')[1];
										
										if (e.type == "DDMoveTo"){
											t = deviceController.getDadaHeightFromCocos(t);
										}
										
										e.cfg1 = cfg1.split(',')[0];
										e.cfg11 = t;
									}
									else {
										e.cfg1 = cfg1
									}
									
									
									delete e.config;
									tree.sequences[lseq].actions[lact].action.cfg1[e.name] = e;
									
									actionController.spawnContainer[p_scene.id] = actionController.spawnContainer[p_scene.id] || {};
									actionController.spawnContainer[p_scene.id][a.name] = actionController.spawnContainer[p_scene.id][a.name] || {};
									actionController.spawnContainer[p_scene.id][a.name][e.name] = e;
								})
							}
							else {
								
								var cfg1 = a.config[0];
								
								//los atributos numéricos van separados por coma
								if (cfg1.indexOf(',') != -1){
									
									var t = cfg1.split(',')[1];
									
									if (e.type == "DDMoveTo"){
										t = deviceController.getDadaHeightFromCocos(t);
									}
									
									tree.sequences[lseq].actions[lact].action.cfg1 = cfg1.split(',')[0];
									tree.sequences[lseq].actions[lact].action.cfg11 = t;
								}
								else {
									tree.sequences[lseq].actions[lact].action.cfg1 = cfg1
								}
								
								if (a.config.length > 1){
									tree.sequences[lseq].actions[lact].action.cfg11 = a.config[1];
								}
							}
							
							
						}
					})
					
					idSq++;
				})
			}
		}
	}
	
	
}